﻿using Cik.Gapi4Net;
using LanguageTranslator.UI.Models;

namespace LanguageTranslator.UI.Services
{
    public class LanguageTranslatorService : ILanguageTranslatorService
    {
        private IGApi4Net _gapi4net;

        public LanguageTranslatorService()
            : this(new GApi4Net())
        {
        }

        public LanguageTranslatorService(IGApi4Net gapi4net)
        {
            _gapi4net = gapi4net;
        }

        public TranslateLanguageModel TranslateLanguage(string inputText, string languagePair)
        {
            var result = _gapi4net.TranslateSearch("1.0", inputText, languagePair);
            return new TranslateLanguageModel { TranslatedText = result.ResponseData.TranslatedText };
        }
    }

    public interface ILanguageTranslatorService
    {
        TranslateLanguageModel TranslateLanguage(string inputText, string languagePair);
    }
}